package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.TSCServiceType;
import com.shrcl.engineerprocess.domain.TSCServiceTypeOptionItem;
import com.shrcl.engineerprocess.domain.impl.TSCServiceTypeImpl;
import com.shrcl.engineerprocess.domain.proxy.TSCServiceTypeOptionItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("TSCSERVICETYPEOPTIONITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "tscservicetypeoptionitem")
public class TSCServiceTypeOptionItemImpl extends BaseModelObject implements TSCServiceTypeOptionItem {
  public TSCServiceTypeOptionItemImpl() {
    super();
  }
  
  public TSCServiceTypeOptionItemImpl(final TSCServiceType serviceType) {
    super();
    this.serviceType = serviceType;
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public TSCServiceTypeOptionItem setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  @JoinColumn(name = "serviceType_id")
  @ManyToOne(targetEntity = TSCServiceTypeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private TSCServiceType serviceType;
  
  public TSCServiceType getServiceType() {
    return this.serviceType;
  }
  
  public TSCServiceTypeOptionItem setServiceType(final TSCServiceType serviceType) {
    this.serviceType = serviceType;
    return this;			
    
  }
  
  public String getEntityName() {
    return this.name;
  }
  
  public static TSCServiceTypeOptionItem create(final TSCServiceType serviceType, final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.TSCServiceTypeOptionItem tSCServiceTypeOptionItem = new com.shrcl.engineerprocess.domain.impl.TSCServiceTypeOptionItemImpl(
    	serviceType
    );
    objectFactory.create(tSCServiceTypeOptionItem);
    return tSCServiceTypeOptionItem;			
    
  }
  
  public static TSCServiceTypeOptionItem createTSCServiceTypeOptionItemImpl(final TSCServiceType serviceType, final IObjectFactory objectFactory, final Procedure1<TSCServiceTypeOptionItem> init) {
    com.shrcl.engineerprocess.domain.TSCServiceTypeOptionItem tSCServiceTypeOptionItem = new com.shrcl.engineerprocess.domain.impl.TSCServiceTypeOptionItemImpl(
    	serviceType
    );
    objectFactory.create(tSCServiceTypeOptionItem);
    init.apply(tSCServiceTypeOptionItem);
    
    return tSCServiceTypeOptionItem;			
    
  }
  
  public TSCServiceTypeOptionItemProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.TSCServiceTypeOptionItemProxy proxy = new com.shrcl.engineerprocess.domain.proxy.TSCServiceTypeOptionItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
